package com.smartalarmclock.UI.Games;

import java.util.Random;

import com.smartalarmclock.UI.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class TextInputActivity extends Activity {
	
	private TextView m_TextInputText;
	private Button m_ButtonStopAlarm;
	private EditText m_Result;
	private int m_MsgToDisplay;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.game_input_text);
		
		Random random = new Random();
		m_MsgToDisplay = random.nextInt(9-0);
		addListenerOnButton();
	}

	private void addListenerOnButton() {
		m_TextInputText = (TextView) findViewById(R.id.textViewMsgToCopy);
		m_ButtonStopAlarm = (Button) findViewById(R.id.buttonStopAlarmOnInputText);
		m_Result = (EditText) findViewById(R.id.editTextResOnInputText);
		
		m_TextInputText.setText(setMsg(m_MsgToDisplay));
		
		m_ButtonStopAlarm.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {			
				String res = m_Result.getText().toString();
				String originalTxt = m_TextInputText.getText().toString();
				
				if(res.equals(originalTxt))
				{
					String msgToUser = "You success with the text input challenge\n Have a nice day";
					Toast.makeText(TextInputActivity.this, msgToUser, Toast.LENGTH_LONG).show();
					finish();
				}
				
				else
				{
					String msgToUser = "You fail with the text input challenge\n Please try again";
					Toast.makeText(TextInputActivity.this, msgToUser, Toast.LENGTH_LONG).show();
				}
					
			  }
			});
	}

	private String setMsg(int msgToDisplay) {
		
		String msg;
		
		switch(msgToDisplay){
		case 1:
			msg = "PLease type this message\n" +
					"Notice To all CAPITAL letters";
			break;
		case 2:
			msg = "12345654321qwertyasdfgh\n" +
					"What the hell?!?";
			break;
		case 3:
			msg = "I hope you sleep well\n" +
					"Have a nice day";
			break;
		case 4:
			msg = "I you want want to stop the alarm\n" +
					"you should type this message";
			break;
		case 5:
			msg = "1+2+3=6\n" +
					"2+3+4=9\n"+
					"3+4+5=12\n";
			break;
		case 6:
			msg = "Broke me if you cant type this message\n" +
					":):):):):):):):):):):)";
			break;
		case 7:
			msg = "(_8^(|) Homer Simpson\n" +
					"@@@@:-) Marge Simpson";
			break;
		case 8:
			msg = "<(-'.'-)> Puppy dog\n" +
					"it's a straight-on smiley";
			break;
		case 9:
			msg = "If you lika the SAC app\n" +
					"jump twice and smile :)";
			break;
		default: 
			msg = "If you lika the SAC app\n" +
					"jump twice and smile :)";
		}
		
		return msg;
	}
			
			

}
